package com.zms.maze;

import java.awt.Point;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.List;

public abstract class Character implements IMoving,Cloneable {
	protected int x;
	protected int y;
	
	public Character(int x,int y)
	{
		this.x=x;
		this.y=y;
	}
	public abstract void writeObject(ObjectOutputStream out) throws IOException	;
	
	public int getX()
	{
		return x;
	}
	public int getY()
	{
		return y;
	}
	public Point getPosition()
	{
		return new Point(x, y);
	}
	@Override
	public void moveLeft()
	{
		x-=1;
	}
	@Override
	public void moveRight() {
		x+=1;
		
	}
	@Override
	public void moveDown() {
		y+=1;
		
	}
	@Override
	public void moveUp() {
		y-=1;
	}
	public String getPosString()
	{
		return "("+String.valueOf(x)+","+String.valueOf(y)+")";
	}
	
	protected Character clone() 
	{
		try
		{
			return (Character) super.clone();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}

}
